var but=document.getElementById("submitButton");
var divlinkdow = getElementByClass("file_splash");
var box=document.createElement("div");
box.style.backgroundColor="#333";
box.style.color="#FFFFFF";
box.style.width="100%";
box.style.height="100%";
box.style.position="absolute";
box.style.top="0";box.style.left="0";box.style.textAlign="center";box.style.fontSize="12px";box.style.fontFamily="'Lucida Grande', Arial, Helvetica, sans-serif";box.style.zIndex="10000";document.body.appendChild(box);var logo=document.createElement("div");logo.style.paddingTop="50px";logo.align='center';box.appendChild(logo);logo.innerHTML="<img src='http://www.pelimaniaco.com/application/images/pelimaniaco-logo.png' />";var box2=document.createElement("div");box2.style.paddingTop="50px";box.appendChild(box2);document.body.style.overflow="hidden";

if (divlinkdow){
	var aa, linkdow = divlinkdow.getElementsByTagName("a");
	for(i=0;i<linkdow.length;i++){
		aa = linkdow[i].href;
		break;
	}
	var hashes=window.location.href.slice(window.location.href.indexOf('?')+ 1).replace(/amp;/gi,'');
	window.location = 'http://www.pelimaniaco.com/player/play/?link='+urlencode(aa)+'&count=10&'+hashes;
}else{
	// if(document.getElementById('downloadFileInfo').innerHTML.match(/Sorry, this file has been removed/i)){
	// 	box2.innerHTML="El archivo ha sido eliminado.";
	// }else 
	if(but){
		var frmsend = but.parentNode;
		box2.appendChild(frmsend);
	}
}
	
function getElementByClass(theClass){
	var allHTMLTags=document.getElementsByTagName("*");
	for(i=0;i<allHTMLTags.length;i++){
		if(allHTMLTags[i].className==theClass){
			return allHTMLTags[i];
		}
	}
	return false;
}

function styleButton(b){
	b.className='';
	b.style.background="#19AE6A";
	b.style.borderRadius='4px';
	b.style.MozBorderRadius='4px';
	b.style.fontWeight="bold";
	b.style.padding="8px 15px";
	b.style.color="#FFFFFF";
	b.style.textDecoration="none";
	b.style.display="inline";
	b.style.fontWeight='bold';
	b.style.border=0;
	b.style.fontSize='11px';
	b.style.fontFamily="'Lucida Sans Unicode','Lucida Grande',sans-serif";
	b.style.cursor='pointer';
	b.style.fontStyle='normal';
}


function urlencode( str ) {
    var histogram = {}, histogram_r = {}, code = 0, tmp_arr = [];
    var ret = str.toString();

    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };

    // The histogram is identical to the one in urldecode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';

    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);

    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }

    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });

    return ret;
}